/*
=======================================================================

  BOTS Class Join Menu

=======================================================================
*/

#include "ui_local.h"
#include "ui_BOTS.h"

typedef struct {
	menuframework_s	menu;

	menutext_s		captain;
	menutext_s		bodyguard;
	menutext_s		sniper;
	menutext_s		soldier;
	menutext_s		berzerker;
	menutext_s		infiltrator;
	menutext_s		kamikazee;
	menutext_s		nurse;
	menutext_s		scientist;
	menutext_s		cancel;
} classmenu_t;

static classmenu_t	s_classmenu;


/*
=================
BOTS_ClassJoinMenu_Event
callback routine
=================
*/
void BOTS_ClassJoinMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
	{
		return;
	}

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id )
	{
	case BOTS_CANCEL:
		break;
	case BOTS_CAPTAIN:
		trap_Cmd_ExecuteText( EXEC_INSERT, "captain\n" );
		break;
	case BOTS_BODYGUARD:
		trap_Cmd_ExecuteText( EXEC_INSERT, "bodyguard\n" );
		break;
	case BOTS_SNIPER:
		trap_Cmd_ExecuteText( EXEC_INSERT, "sniper\n" );
		break;
	case BOTS_SOLDIER:
		trap_Cmd_ExecuteText( EXEC_INSERT, "soldier\n" );
		break;
	case BOTS_BERZERKER:
		trap_Cmd_ExecuteText( EXEC_INSERT, "berzerker\n" );
		break;
	case BOTS_INFILTRATOR:
		trap_Cmd_ExecuteText( EXEC_INSERT, "infiltrator\n" );
		break;
	case BOTS_KAMIKAZEE:
		trap_Cmd_ExecuteText( EXEC_INSERT, "kamikazee\n" );
		break;
	case BOTS_NURSE:
		trap_Cmd_ExecuteText( EXEC_INSERT, "nurse\n" );
		break;
	case BOTS_SCIENTIST:
		trap_Cmd_ExecuteText( EXEC_INSERT, "scientist\n" );
		break;
		
	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_ClassJoinMenu_Init
=================
*/
void BOTS_ClassJoinMenu_Init( void ) 
{
	int		y;

	memset( &s_classmenu, 0 ,sizeof(classmenu_t) );

	s_classmenu.menu.wrapAround = qtrue;
	s_classmenu.menu.fullscreen = qfalse;

	y = 96;
	s_classmenu.captain.generic.type		= MTYPE_PTEXT;
	s_classmenu.captain.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.captain.generic.x			= 320;
	s_classmenu.captain.generic.y			= y;
	s_classmenu.captain.generic.id			= BOTS_CAPTAIN;
	s_classmenu.captain.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.captain.string				= "CAPTAIN";
	s_classmenu.captain.color				= color_bots_menu;
	s_classmenu.captain.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.bodyguard.generic.type		= MTYPE_PTEXT;
	s_classmenu.bodyguard.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.bodyguard.generic.x			= 320;
	s_classmenu.bodyguard.generic.y			= y;
	s_classmenu.bodyguard.generic.id		= BOTS_BODYGUARD;
	s_classmenu.bodyguard.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.bodyguard.string			= "BODYGUARD";
	s_classmenu.bodyguard.color				= color_bots_menu;
	s_classmenu.bodyguard.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.sniper.generic.type		= MTYPE_PTEXT;
	s_classmenu.sniper.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.sniper.generic.x		= 320;
	s_classmenu.sniper.generic.y		= y;
	s_classmenu.sniper.generic.id		= BOTS_SNIPER;
	s_classmenu.sniper.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.sniper.string			= "SNIPER";
	s_classmenu.sniper.color			= color_bots_menu;
	s_classmenu.sniper.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.soldier.generic.type		= MTYPE_PTEXT;
	s_classmenu.soldier.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.soldier.generic.x			= 320;
	s_classmenu.soldier.generic.y			= y;
	s_classmenu.soldier.generic.id			= BOTS_SOLDIER;
	s_classmenu.soldier.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.soldier.string				= "SOLDIER";
	s_classmenu.soldier.color				= color_bots_menu;
	s_classmenu.soldier.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.berzerker.generic.type		= MTYPE_PTEXT;
	s_classmenu.berzerker.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.berzerker.generic.x			= 320;
	s_classmenu.berzerker.generic.y			= y;
	s_classmenu.berzerker.generic.id		= BOTS_BERZERKER;
	s_classmenu.berzerker.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.berzerker.string			= "BERZERKER";
	s_classmenu.berzerker.color				= color_bots_menu;
	s_classmenu.berzerker.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.infiltrator.generic.type		= MTYPE_PTEXT;
	s_classmenu.infiltrator.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.infiltrator.generic.x			= 320;
	s_classmenu.infiltrator.generic.y			= y;
	s_classmenu.infiltrator.generic.id			= BOTS_INFILTRATOR;
	s_classmenu.infiltrator.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.infiltrator.string				= "INFILTRATOR";
	s_classmenu.infiltrator.color				= color_bots_menu;
	s_classmenu.infiltrator.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.kamikazee.generic.type		= MTYPE_PTEXT;
	s_classmenu.kamikazee.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.kamikazee.generic.x			= 320;
	s_classmenu.kamikazee.generic.y			= y;
	s_classmenu.kamikazee.generic.id		= BOTS_KAMIKAZEE;
	s_classmenu.kamikazee.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.kamikazee.string			= "KAMIKAZEE";
	s_classmenu.kamikazee.color				= color_bots_menu;
	s_classmenu.kamikazee.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.nurse.generic.type		= MTYPE_PTEXT;
	s_classmenu.nurse.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.nurse.generic.x			= 320;
	s_classmenu.nurse.generic.y			= y;
	s_classmenu.nurse.generic.id		= BOTS_NURSE;
	s_classmenu.nurse.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.nurse.string			= "NURSE";
	s_classmenu.nurse.color				= color_bots_menu;
	s_classmenu.nurse.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.scientist.generic.type		= MTYPE_PTEXT;
	s_classmenu.scientist.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.scientist.generic.x			= 320;
	s_classmenu.scientist.generic.y			= y;
	s_classmenu.scientist.generic.id		= BOTS_SCIENTIST;
	s_classmenu.scientist.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.scientist.string			= "SCIENTIST";
	s_classmenu.scientist.color				= color_bots_menu;
	s_classmenu.scientist.style				= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_classmenu.cancel.generic.type		= MTYPE_PTEXT;
	s_classmenu.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_classmenu.cancel.generic.x		= 320;
	s_classmenu.cancel.generic.y		= y;
	s_classmenu.cancel.generic.id		= BOTS_CANCEL;
	s_classmenu.cancel.generic.callback	= BOTS_ClassJoinMenu_Event; 
	s_classmenu.cancel.string			= "CANCEL";
	s_classmenu.cancel.color			= color_bots_menu;
	s_classmenu.cancel.style			= UI_CENTER|UI_SMALLFONT;

	//Menu_AddItem( &s_classmenu.menu, &s_classmenu.captain );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.bodyguard );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.sniper );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.soldier );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.berzerker );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.infiltrator );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.kamikazee );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.nurse );
	//Menu_AddItem( &s_classmenu.menu, &s_classmenu.scientist );
	Menu_AddItem( &s_classmenu.menu, &s_classmenu.cancel );
}

/*
=================
BOTS_ClassJoinMenu_f
=================
*/
void BOTS_ClassJoinMenu_f( void ) {
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	BOTS_ClassJoinMenu_Init();
	UI_PushMenu( &s_classmenu.menu );
}
